/**
 * HelloWorldController.java
 * com.sftz.demo.controller
 * Copyright (c) 2018, 北京科技有限公司版权所有.
*/

package com.sftz.sso.modules.test.controller;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.sftz.sso.modules.test.form.UserForm;
import com.sftz.sso.modules.test.service.HelloWorldService;

/**
 * RestController注解表示controller中的方法都以json格式输出，无需再写jackjson配置
 * 
 * @author   朱晓川
 * @Date	 2018年9月26日 	 
 */
@RestController
public class HelloWorldController {

	@Resource
	protected HelloWorldService helloWorldService;

	@RequestMapping("/hello")
	public String hello() {
		return "Hello World.";
	}

	/**
	 * 路径参数
	 */
	@RequestMapping(value = "/user/{id}", method = RequestMethod.GET)
	public Object user(@PathVariable("id") Integer id) {
		return helloWorldService.findUserById(id);
	}

	/**
	 * 对象接收参数
	 */
	@RequestMapping(value = "/form", method = RequestMethod.GET)
	public Object user(UserForm form) {
		long id = form.getId();
		return helloWorldService.findUserById(id);
	}

}
